#include <unordered_map>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    unordered_map<string, int> s;
    string tmp;
    int n;
    scanf("%d\n", &n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 8; ++j)
        {
            string s;
            cin >> s;
            tmp += s;
        }
        s[tmp]++;
        printf("%d\n", s[tmp]);
        tmp.clear();
    }
    return 0;
}